package service

import (
	"gitee.com/gopher2011/mall/app/dao"
	"time"
)

// 全局公开对象
var UmsResourceCategory = umsResourceCategoryService{}

// 私有对象，所有的方法都绑定到这个结构体上。
type umsResourceCategoryService struct{}

func (p *umsResourceCategoryService) Create(a *dao.UmsResourceCategory) (int64, error) {
	a.CreateTime = time.Now()
	return dao.UmsResourceCategoryDao.InsertTemplate(*a)
}

func (p *umsResourceCategoryService) Update(id int64, a *dao.UmsResourceCategory) (int64, error) {
	a.Id = id
	return dao.UmsResourceCategoryDao.UpdateById(*a)
}

func (p *umsResourceCategoryService) Delete(id int64) (int64, error) {
	return dao.UmsResourceCategoryDao.DeleteById(id)
}

func (p *umsResourceCategoryService) ListAll() ([]dao.UmsResourceCategory, error) {
	return dao.UmsResourceCategoryDao.ListAll()
}
